<?php

namespace Cblood\Route\Http;


class HttpResponseResult
{
    const RESPONSE_XML = 1;
    const RESPONSE_VIEW = 2;
    const RESPONSE_JSON = 3;
    const RESPONSE_SKIP = 4;
    const RESPONSE_IMAGE = 5;
    const RESPONSE_ERROR = 6;
    const RESPONSE_DOWNLOAD = 7;


    protected $handle;
    protected $url;         //跳转用
    protected $filePath;    //图片和下载用
    protected $template;    //输出html文件用
    protected $params;      //输出html、json、xml、error用，用于传输变量

    public function __construct($handle, $params = [])
    {
        $this->handle = $handle;
        foreach ($params as $name => $value) {
            if (property_exists($this, $name)) {
                $this->$name = $value;
            }
        }
    }

    /**
     * @return mixed
     */
    public function getHandle()
    {
        return $this->handle;
    }

    /**
     * @return mixed
     */
    public function getUrl()
    {
        return $this->url;
    }

    /**
     * @return mixed
     */
    public function getFilePath()
    {
        return $this->filePath;
    }

    /**
     * @return mixed
     */
    public function getTemplate()
    {
        return $this->template;
    }

    /**
     * @return mixed
     */
    public function getParams()
    {
        return $this->params;
    }
}